// app.js
App({
    onLaunch() {
        // 通过token判断是否登录
        // wx.removeStorageSync('token');

        // 获取语言版本
        wx.getSystemInfo({
            success: (res) => {
                this.globalData.isZh = res.language.includes('zh');
            }
        })
        // 判断是否过期
        let bindTIme = wx.getStorageSync('bindTime');
        if (bindTIme) {
            let duration = (Date.now() - bindTIme) / 1000;
            let d = Math.floor(duration / 60 / 60 / 24);
            let h = Math.floor(duration / 60 / 60 % 24);
            let m = Math.floor(duration / 60 % 60);
            let s = Math.floor(duration % 60);
            // console.log('已绑定设备' + d + '天' + h + '小时' + m + '分' + s + '秒');
            if (duration > 14 * 24 * 60 * 60) {
                wx.removeStorageSync('deviceId');
            }
        }
        // 登录
        wx.login({
            success: res => {
                // 发送 res.code 到后台换取 openId, sessionKey, unionId
                // console.log(res);
            }
        })
    },
    globalData: {
        userInfo: null,
        isZh: true,
        baseURL: "http://www.blf-data.cn/prod-api"
    }
})
